package com.googlecode.lookie.platform.laf;

import org.springframework.richclient.settings.Settings;

import com.googlecode.lookie.platform.settings.SettingsIds;
import com.googlecode.lookie.swing.laf.LookAndFeelDescriptor;
import com.googlecode.lookie.swing.laf.LookAndFeelRegistry;

public class LookAndFeelRegistryHelper
{

    public static LookAndFeelDescriptor getPreferredDescriptor( LookAndFeelRegistry registry, Settings settings )
    {

        LookAndFeelDescriptor descriptor = null;
        String id = null;

        id = settings.getString( SettingsIds.LAF );
        if ( id != null )
        {
            descriptor = registry.getDescriptor( id );
        }

        if ( descriptor == null )
        {
            id = settings.getDefaultString( SettingsIds.LAF );
            if ( id != null )
            {
                descriptor = registry.getDescriptor( id );
            }
        }

        return descriptor;
    }

}
